.PHONY: all build clean run check cover lint docker help

BIN_FILE=leaderboard_rpc
BUILD_TIME=`date +%Y%m%d.%H%M`

build:
	@go build -o "${BIN_FILE}"
clean:
	@go clean -o "${BIN_FILE}"
run:
	@goctl model mysql ddl --home $(PWD)/../../../goctl_tpl  -src="../model/*.sql" -dir="../model/" -c
	@goctl rpc protoc leaderboard.proto --home $(PWD)/../../../goctl_tpl --go_out=./types --go-grpc_out=./types --zrpc_out=.
	@go run leaderboard.go -f etc/leaderboard.yaml
run-home:
	@goctl model mysql ddl --home $(PWD)/../../../goctl_tpl  -src="../model/*.sql" -dir="../model/" -c
	@goctl rpc protoc leaderboard.proto --home $(PWD)/../../../goctl_tpl --go_out=./types --go-grpc_out=./types --zrpc_out=.
	@go run leaderboard.go -f etc/leaderboard-home.yaml
docker:
	if [ -a Dockerfile ]; then rm Dockerfile; fi;
	@goctl docker --go leaderboard.go --port 8082
	@cd $(PWD)/../../../ && pwd &&  docker build -t sms:${BUILD_TIME} -f service/sms/rpc/Dockerfile .
	@echo "镜像打包完成 版本为: leaderboard:${BUILD_TIME}"

help:
	@echo "make 格式化go代码 并编译生成二进制文件"
	@echo "make build 编译go代码生成二进制文件"
	@echo "make clean 清理中间目标文件"
	@echo "make test 执行测试case"
	@echo "make check 格式化go代码"
	@echo "make cover 检查测试覆盖率"
	@echo "make run 直接运行程序"
	@echo "make lint 执行代码检查"
	@echo "make docker 构建docker镜像"
	